<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button class="btn_get">GET请求</button>
  <button class="btn_post">POST请求</button>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <script>
    axios.defaults.baseURL = 'http://192.168.2.57:8090/'
    // 添加请求拦截器
    axios.interceptors.request.use((config) => {
      console.log(config.url);
      config.headers.token = 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzE1OTE1OTU3LCJleHAiOjE3MTU5NjYwMjJ9.ZjeckRuSMHpsojotO9AgCjWhDC40TocM7oXCJq9EsjqttzHseBbr8hbByDsTmKtpxLqkM76XD5oGvkAN6TeKrg'
      return config
    }, (error) => {
      console.log(error);
    })
    // document.querySelector('.btn_get').addEventListener('click', () => {
    //   axios.get('getaxios3/1001').then(result => {
    //     console.log(result);
    //     console.log(result.data);
    //   }).catch(error => {
    //     console.log('错误');
    //   }).finally(() => {
    //     console.log('最终都会执行的');
    //   })
    // })
    document.querySelector('.btn_post').addEventListener('click', () => {
      axios.post('/employee/lists', {
        "status": "在职"
      }
        // , {
        //   headers: {
        //     "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzE1OTE1OTU3LCJleHAiOjE3MTU5NjYwMjJ9.ZjeckRuSMHpsojotO9AgCjWhDC40TocM7oXCJq9EsjqttzHseBbr8hbByDsTmKtpxLqkM76XD5oGvkAN6TeKrg"
        //   }
        // }
      ).then(result => {
        console.log(result);
        console.log(result.data);
      }).catch(error => {
        console.log('错误');
      }).finally(() => {
        console.log('最终都会执行的');
      })
    })

  </script>
</body>

</html>